home *** CD-ROM | disk | FTP | other *** search
-
- Listing 3
- =========
-
- /* Return all memory allocated to this ID */
-
- /* NULL is returned on error */
-
- unsigned int deiniz_borrow(id)
- register MemBlock *id;
- {
- register MemBlock *nextone=id, /* Pointer to next block */
- *thisone; /* Pointer to pres block */
-
- while(thisone=nextone) { /* While blocks to return */
- nextone=thisone->mb_next; /* Point to next block */
- if(deallocate(thisone)==0) /* Return this one */
- return(NULL);
- }
-
- return(id); /* Return non-zero */
- }
-
-
- /* ---------------------------------------------------------- */
-
- /* Return all memory but the first block */
-
- /* NULL is returned on error */
-
- unsigned int return_borrow(id)
- register MemBlock *id;
- {
- register MemBlock *nextone, /* Pointer to next block */
- *thisone; /* Pointer to pres block */
-
- /* Return all but first */
- if(nextone=id->mb_next) /* If anything to return */
- while(thisone=nextone) { /* While blocks to return */
- nextone=thisone->mb_next; /* Point to next block */
- if(deallocate(thisone)==0) /* Return this one */
- return(NULL);
- }
-
- /* Reset infomation in the first block */
- id->mb_next=NULL; /* No next block */
- id->mb_pres=id; /* This is the present one */
- id->mb_offs=sizeof(MemBlock); /* Reset offset */
-
- return(id); /* Return non-zero */
- }
-
-